<template>
  <div>
      <h3 class="title">注册</h3>
      {{user}}
      <div>
        <input type="text" v-model="user.phone" placeholder="手机号">
      </div>
      <div>
        <input type="text" v-model="user.nickname" placeholder="昵称">
      </div>
      <div>
        <input type="text" v-model="user.password" placeholder="密码">
      </div>
      <button @click="register">注册</button>
  </div>
</template>

<script>
import  {reqRegister}  from "../../http/http";
export default {
  data() {
    return {
      // 2.初始化数据
      user: {
        phone: "",
        nickname: "",
        password: "",
      },
    };
  },
  methods:{
    // 4.注册
    register(){
     
      //发请求
      reqRegister().then(res=>{
        if(res.data.code==200){
          //成功
          alert(res.data.msg)
          //跳转登录
          this.$router.push("/login")
        }else{
          //失败
           alert(res.data.msg)
        }
      })
    }
  }
};
</script>

<style>

</style>